<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Pdf_rincian_candah extends CI_Controller {

    public function index()
    {
	    $filename = "s.pdf";
	    $content = shell_exec('pdftotext -raw '.$filename.' -');

	    $separator = "\r\n";
	    $line = strtok($content, $separator);

	    $i=0;
	    $j=0;

	    while ($line !== false) {
	        $i++;

	        if ($line == 'Issue'){
	            $j++;

	            $data = new stdClass();

	            $data->muhasil = strtok( $separator );
	            $data->jumlah  = strtok( $separator );
	            $data->no_m1   = strtok( $separator );
	            $data->periode = strtok( $separator );
	            $data->nama    = strtok( $separator );
	            $data->aims    = strtok( $separator );
	            list($data->tanggal, $data->metode) = explode(' ', strtok( $separator ));

	            while (($line = strtok( $separator )) != 'Issue' && ord($line[0])!=12)
	                $data->rincian[]=$line;

	            var_dump($data); echo('<br/>------------------------------------<br/>');
	        }
	        else
	            $line = strtok( $separator );
	    }
    }

}